package youcaihuaoa.weetop.com.vm.main

import android.app.Application
import api.UserServiceFactory
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.common.api.AbstractViewModelSubscriber
import com.robot.base.model.WagesBean
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent
import me.goldze.mvvmhabit.http.BaseResponse

class WagesViewModel(application: Application) : GLBaseViewModel(application) {

    val uiChangeEvent = UiChangeEvent()

    class UiChangeEvent {
        val dataEvent = SingleLiveEvent<List<WagesBean>>()
    }

    fun getUserWagesList() {
        showLoadingDialog()
        UserServiceFactory.getUserWagesList()
            .subscribe(object : AbstractViewModelSubscriber<BaseResponse<List<WagesBean>>>(this) {
                override fun onNext(t: BaseResponse<List<WagesBean>>) {
                    dismissLoadingDialog()
                    t.data?:return
                    uiChangeEvent.dataEvent.postValue(t.data)
                }
            })
    }
}